/**
* Copyright (c) 2016-2100 yunclouds
*/
package com.yunqian.redot.repository;

import com.yunqian.redot.domain.TicketOrderDetails;
import com.yunqian.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author czy
 * 2018-10-15 14:49:22
 */
@Repository
public interface TicketOrderDetailsRepository extends BaseRepository<TicketOrderDetails, Long> {

    /**
     * 多条件查询
     * @param orderNo
     * @param phone
     * @param beginTime
     * @param endTime
     * @return
     */
    @Query(value = "select * from v_ticket_order_details where if(:orderNo != '', order_no = :orderNo, 1 = 1) and if(:phone != '', phone = :phone, 1 = 1) and save_time between :beginTime and :endTime", nativeQuery = true)
    List<TicketOrderDetails> findByOrderNoAndPhoneAndRangeTime(@Param("orderNo") String orderNo, @Param("phone") String phone, @Param("beginTime") String beginTime, @Param("endTime") String endTime);

}
